<template>
	<div class="doc-reference custom-scrollbar">
		<el-alert
		    title="注意:以下文档仅作为参考学习,不得抄袭、剽窃，不得以各种形式破坏、占有他人劳动成果,举报、投诉(qq:1844197266,qq:1136087534)"
		    type="warning">
		  </el-alert>
		<div class="doc_reference-content">
			<el-table :data="tableData" style="width: 100%">
				<el-table-column label="日期">
					<template slot-scope="scope">
						<i class="el-icon-time"></i>
						<span style="margin-left: 10px">{{ scope.row.time | $_formatDate }}</span>
					</template>
				</el-table-column>
				<el-table-column label="学校" prop="university">
				</el-table-column>
				<el-table-column label="文档名称" prop="docName">
				</el-table-column>
				<el-table-column label="贡献者" prop="author">
				</el-table-column>
				<el-table-column label="文档类型" prop="type">
				</el-table-column>
				<el-table-column label="操作">
					<template slot-scope="scope">
						<el-button size="mini" type="primary" @click="handlePreviewDowonload(scope.$index, scope.row)">预览&下载</el-button>
					</template>
				</el-table-column>
			</el-table>
		</div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				tableData: [],
			}
		},
		created() {
			this.getCurPageData()
		},
		methods: {
			 async getCurPageData() {
				let res = await this.$network({
					api:"getDocReference"
				})
				
				if(res.status === 0){
					this.tableData = res.data
				}
			},
			handlePreviewDowonload(index, row) {
				if (!/\.(pdf|PDF)$/.test(row.docPath)) {
				  window.open(
				    "https://view.officeapps.live.com/op/view.aspx?src=" + row.docPath,
				    "_blank"
				  );
				  return false;
				} else {
					// pdf可以直接打开连接（？）
					window.open(row.docPath)
				}
			}
		}
	}
</script>

<style lang="scss">
	.doc-reference {
		height: 100%;
		.doc_reference-content {}
	}
</style>
